﻿using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;

namespace FDSimpleModelGenerator.Common
{
    public class EncryptUtil
    {
        private static readonly string AppKeySign = "DraleeGenerate2019key";
        private static readonly string AppSecretSign = "draleenice42019sec";

        /// <summary>
        /// 加密
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static string Encrypt(string data)
        {
            var str = $"{AppKeySign}{data}{AppSecretSign}";
            using var md5 = MD5.Create();
            var result = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
            var sb = new StringBuilder();
            foreach (var b in result)
            {
                sb.Append(b.ToString("x2"));
            }

            return sb.ToString();
        }
    }
}
